import { defineStore } from 'pinia';
import { get_web_url } from '@/utils/config.js';
import { init_page } from '@/utils/utils.js';

export const useIndexStore = defineStore('index', {
    // data
    state: () => ({
        img_src: require('@/assets/img/bg_hp.mp4'),
        count_down: null,
        start: null,
        msak_is_none: false,
        user_info: {
            user_name:"",
            user_img:"",
            user_permissions:null,
            user_id:null
        },
        web_url: null,
    }),
    // 计算属性
    getters: {},
    // 方法
    actions: {
        update_img_src(src) {
            this.img_src = src;
        },
        update_countdown(value) {
            this.count_down = value;
        },
        update_start(value) {
            this.start = value;
        },
        update_msak_is_none(value) {
            this.msak_is_none = value;
        },
        async update_user_info_init() {
            let user_info = await init_page(this);
            this.user_info = user_info;
        },
        async update_web_url() {
            let web_url = await get_web_url(false);
            this.web_url = web_url;
        },
        update_user_info(user_info) {
            this.user_info = user_info;
        },
    },
});
